home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / March 96 / Re Initializing an Extension < prev    next >
Encoding:
Internet Message Format  |  1996-12-03  |  2.8 KB  |  [TEXT/ttxt]

  1. Subject:     Re: Initializing an Extension
  2. Sent:        3/5/96 4:27 PM
  3. Received:    3/5/96 4:41 PM
  4. From:        Troy Gaul, tgaul@apple.com
  5. Reply-To:    ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. >Damon describes the static method MyCreateXYZProc which makes the call: 
  9. >
  10. >>        theExtension -> InitMySOMNautilusShellExtension (ev, part ->
  11. >>              GetODPart (ev));
  12. >
  13. >OK, so consider InitMySOMNautilusShellExtension. There I would like to get
  14. >access to an object owned by my part and stash a reference to it in the
  15. >extension. OpenDoc's SoundEditor extension, for example, initializes a field
  16. >
  17. >     SoundEditor*  fOwner
  18. >
  19. >using the call
  20. >
  21. >    fOwner = ((SampleCode_som_SoundEditor*) owner->GetRealPart(ev))
  22. >                    ->GetImplementation(ev);
  23.  
  24. This was an unfortunage decision, as it means that the SOM object must 
  25. have the additional function GetImplementation, and as you can see, you 
  26. have to call GetRealPart/ReleaseRealPart to get access to the part 
  27. through the part wrapper.  Instead, the SoundEditor example could have 
  28. defined it's InitXxxxExtension routine to take a SoundEditor* as a 
  29. parameter.  This was actually suggested to me, but too late to make the 
  30. change.  (I worked on maintenence for the SoundEditor sample part -- I 
  31. didn't design the way this was done, though.)
  32.  
  33. >How do I do that in ODF? The GetRealPart method will return an ODPart, but
  34. >what I really want is my FW_CPart, the one, if I understand things correctly,
  35. >that is holding onto the ODPart in its fODPart field. (I want my FW_CPart
  36. >because it has a pointer to an object that I want to stash in my extension
  37. >and refer to from another part.)
  38.  
  39. Since the FW_CPart is passed into the creation proc, you can pass that 
  40. along to your extension subclass, like:
  41.  
  42. ODExtension* 
  43. CMyPart::MyCreateXYZProc(Environment* ev, FW_CPart* part, const char* 
  44. name)
  45. {
  46.     SOM_MyXYZExtension* theExtension = new 
  47. SOMXTN_MySOMNautilusShellExtension();
  48.     theExtension->InitMyExtension(ev, (CMyPart*) part);
  49.  
  50.     return theExtension;
  51. }
  52.  
  53. Since you are the one defining your Init routine, you can define it with 
  54. whatever parameters you want.  However, since ODF calls your creating 
  55. proc and the creation proc has the given set of parameters, that's all 
  56. the information you really get access to when initing your extension.  
  57.  
  58. Since the FW_CPart is passed in, though, (and you know that this will 
  59. actually be of type CMyPart or whatever) you can pass this into your 
  60. extensions Init routine, or you can get information from the part and 
  61. pass that to the extension instead.
  62.  
  63. _troy
  64.  
  65. ......................................................................
  66.  Troy Gaul                                            tgaul@apple.com
  67.  Apple Computer, Inc.                    OpenDoc Added Value Products
  68. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  69.  
  70.